package com.softtown.modules.workflow.controller;

import com.softtown.common.annotation.LogOperation;
import com.softtown.common.utils.Result;
import com.softtown.modules.workflow.dto.SwfNextAprvDefDTO;
import com.softtown.modules.workflow.entity.SwfNextAprvDefEntity;
import com.softtown.modules.workflow.service.SwfNextAprvDefService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: Dingyayong
 * @Date: 2019/8/22 16:31
 * @Description:
 */
@RestController
@RequestMapping("swf/nextAprv")
@Api(tags = "下一审批人默认值")
public class SwfNextAprvDefController {

    @Resource
    private SwfNextAprvDefService swfNextAprvDefService;

    /**
     * 出差申请获取下一审批人默认值
     *
     * @param swfNextAprvDefDTO 下一审批默认值DTO
     * @return com.softtown.common.utils.Result<com.softtown.modules.entity.SwfNextAprvDefEntity>
     * @Author Dingyayong
     * @Date 2020/4/13 17:11
     */
    @PostMapping("getNextAprvt")
    @ApiOperation("出差申请获取下一审批人默认值")
    @LogOperation("出差申请获取下一审批人默认值")
    public Result<SwfNextAprvDefEntity> getNextAprvt(@RequestBody SwfNextAprvDefDTO swfNextAprvDefDTO) {
        SwfNextAprvDefEntity
                swfNextAprvDefEntity = swfNextAprvDefService.getNextAprvt(swfNextAprvDefDTO.getUserId(), swfNextAprvDefDTO.getCompId());
        return new Result<SwfNextAprvDefEntity>().ok(swfNextAprvDefEntity);
    }

    /**
     * 差旅报销申请申请获取下一审批人默认值
     *
     * @param swfNextAprvDefDTO 下一审批默认值DTO
     * @return com.softtown.common.utils.Result<com.softtown.modules.entity.SwfNextAprvDefEntity>
     * @Author Dingyayong
     * @Date 2020/4/13 17:12
     */
    @PostMapping("getExpenseNextAprvt")
    @ApiOperation("差旅报销申请申请获取下一审批人默认值")
    @LogOperation("差旅报销申请申请获取下一审批人默认值")
    public Result<SwfNextAprvDefEntity> getExpenseNextAprvt(@RequestBody SwfNextAprvDefDTO swfNextAprvDefDTO) {
        SwfNextAprvDefEntity
                swfNextAprvDefEntity = swfNextAprvDefService.getExpenseNextAprvt(swfNextAprvDefDTO);
        return new Result<SwfNextAprvDefEntity>().ok(swfNextAprvDefEntity);
    }

    /**
     * 借款申请获取下一审批人默认值
     *
     * @param swfNextAprvDefDTO 下一审批默认值DTO
     * @return com.softtown.common.utils.Result<com.softtown.modules.entity.SwfNextAprvDefEntity>
     * @author fuming
     * @date 2019/10/29 13:20
     */
    @PostMapping("getAdvNextAprvDef")
    @ApiOperation("借款申请获取下一审批人默认值")
    @LogOperation("借款申请获取下一审批人默认值")
    public Result<SwfNextAprvDefEntity> getAdvNextAprvDef(@RequestBody SwfNextAprvDefDTO swfNextAprvDefDTO) {
        SwfNextAprvDefEntity advNextAprv = swfNextAprvDefService.getAdvNextAprv(swfNextAprvDefDTO.getUserId(), swfNextAprvDefDTO.getCompId());
        return new Result<SwfNextAprvDefEntity>().ok(advNextAprv);
    }

    /**
     * 获取下一审批人默认值
     *
     * @param swfNextAprvDefDTO 下一审批默认值DTO
     * @return com.softtown.common.utils.Result<com.softtown.modules.entity.SwfNextAprvDefEntity>
     * @Author Dingyayong
     * @Date 2020/4/13 17:13
     */
    @PostMapping("getAllNextAprvt")
    @ApiOperation("获取下一审批人默认值")
    @LogOperation("获取下一审批人默认值")
    public Result<SwfNextAprvDefEntity> getAllNextAprvt(@RequestBody SwfNextAprvDefDTO swfNextAprvDefDTO) {
        SwfNextAprvDefEntity
                swfNextAprvDefEntity = swfNextAprvDefService.getAllNextAprvt(swfNextAprvDefDTO);
        return new Result<SwfNextAprvDefEntity>().ok(swfNextAprvDefEntity);
    }

    /**
     * 获取下一个审批人的上一审批人段终审值
     *
     * @param swfNextAprvDefDTO 下一审批默认值DTO
     * @return com.softtown.common.utils.Result<java.lang.Integer>
     * @Author fuming
     * @Date 2020/3/4 17:12
     */
    @PostMapping("getIsPhaseLastAprv")
    @ApiOperation("获取下一个审批人的上一审批人段终审值")
    @LogOperation("获取下一个审批人的上一审批人段终审值")
    public Result<Integer> getIsPhaseLastAprv(@RequestBody SwfNextAprvDefDTO swfNextAprvDefDTO) {
        Integer isPhaseLastAprvValue = swfNextAprvDefService.selectIsPhaseLastAprv(swfNextAprvDefDTO);
        return new Result<Integer>().ok(isPhaseLastAprvValue);
    }
}
